package day07;

import java.util.Scanner;

public class zy0704 {
    public static void main(String[] args) {
        Scanner scan =new Scanner(System.in);
        System.out.println("请输入机票价格");
        double price = scan.nextDouble();
        System.out.println("请输入月份");
        int month = scan.nextInt();
        System.out.println("选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();
        System.out.println("机票价格为："+calairprice(price,month,type));
        double finalprice=calairprice(price,month,type);
    }
        public static double calairprice(double price,int month,int type) {
            double finalprice = 0.0;
            if (month > 12 || month < 1) {
                System.out.println("月份输入错误");
                return -1;
            }
            if (type < 1 || type > 3) {
                System.out.println("舱位输入错误");
                return -1;
            }
            if (month <= 10 || month >= 5) {
                switch (type) {
                    case 1:
                        finalprice = price * 0.9;
                        break;
                    case 2:
                        finalprice = price * 0.85;
                        break;
                    case 3:
                        finalprice = price * 0.8;
                        break;
                }
            } else {
                switch (type) {
                    case 1:
                        finalprice = price * 0.7;
                        break;
                    case 2:
                        finalprice = price * 0.65;
                        break;
                    case 3:
                        finalprice = price * 0.6;
                        break;

                }

            }
            return finalprice;
        }}
























        /*
        Scanner scan =new Scanner(System.in);
        System.out.println("请输入机票价格");
        double price = scan.nextDouble();
        System.out.println("请输入月份");
        int month = scan.nextInt();
        System.out.println("选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();
        System.out.println("机票价格为："+calairprice(price,month,type));
        double finalprice=calairprice(price,month,type);
    }
    public static double calairprice(double price,int month,int type){
       double finalprice =0.0;
       if (month>12||month<1){
           System.out.println("月份输入错误");
           return -1;
       }
       if (type<1||type>3){
           System.out.println("舱位输入错误");
           return -1;
       }
       if (month<=10||month>=5){
           switch (type){
               case 1:
                   finalprice=price*0.9;
                   break;
               case 2:
                   finalprice=price*0.85;
                   break;
               case 3:
                   finalprice=price*0.8;
                   break;
           }
       }else {
           switch (type){
               case 1:
                   finalprice=price*0.7;
                   break;
               case 2:
                   finalprice=price*0.65;
                   break;
               case 3:
                   finalprice=price*0.6;
                   break;

       }

    }return finalprice;
}
}

         */
